Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(data-structures): ensure size consistency in BinarySearchTree.from #6272

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

jiangshengdev
Copy link
Contributor

Previously, when cloning an existing BinarySearchTree using the static from method, the new tree’s #size field was not updated, leading to a mismatch between the reported size and the actual number of nodes. This commit addresses the issue by directly assigning the original tree’s #size to the new instance after copying all nodes.

Additional tests have been added to verify that size remains accurate and consistent following the cloning process.

@jiangshengdev jiangshengdev requested a review from kt3k as a code owner December 16, 2024 06:56
@CLAassistant
Copy link

CLAassistant commented Dec 16, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.35%. Comparing base (34abfeb) to head (1430277).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6272      +/-   ##
==========================================
- Coverage   96.35%   96.35%   -0.01%     
==========================================
  Files         541      541              
  Lines       41303    41304       +1     
  Branches     6182     6182              
==========================================
  Hits        39798    39798              
- Misses       1463     1464       +1     
  Partials       42       42              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jiangshengdev jiangshengdev changed the title fix(data_structures): ensure size consistency in BinarySearchTree.from fix(data-structures): ensure size consistency in BinarySearchTree.from Dec 16, 2024
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thanks

@kt3k
Copy link
Member

kt3k commented Dec 16, 2024

Note: Confirmed the added assertions fail with the current implementation

@kt3k kt3k merged commit 026a953 into denoland:main Dec 16, 2024
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants